package TrueTopic;


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Stream;

public class TestH {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        while (t-- > 0) {
            int n = sc.nextInt();
            sc.nextLine();
//            String str = "";
//            for(int i=0;i<n;i++) {
//                str+=sc.next();
//            }
//            str = str.replace(" ","");
//            System.out.println(str+" "+str.length());
            int sum = Stream.generate(sc::nextLine).limit(n).mapToInt(String::length).sum();
            System.out.println(sum);
        }

        Set<Integer> set = new HashSet<>();

    }
}
